<!-- 服务商列表 -->
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="关键词" prop="searchValue">
        <el-input
          v-model="queryParams.searchValue"
          placeholder="服务商名称/管理员"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb-8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleOpen()"
          v-hasPermi="['facilitator:facilitator:add']"
          >新增</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="服务商名称" align="center" prop="cname" />
      <el-table-column label="审核状态" align="center" prop="apstatus">
        <template slot-scope="{row}">
          <div class="disFlxCC">
            <dict-tag
              :options="dict.type.apstatus"
              :value="String(row.apstatus)"
            />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="服务商地址" align="center" prop="address" />
      <el-table-column label="管理员" align="center" prop="adminname" />
      <el-table-column label="管理员账号" align="center" prop="adminacc" />
      <el-table-column label="管理员手机号" align="center" prop="mobile" />
      <el-table-column label="服务商余额" align="center" prop="balance" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="所属事业部" align="center" prop="channelName" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="120px"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button v-hasPermi="['facilitator:facilitator:edit']" size="mini" type="text" @click="handleOpen(scope.row.id)"
            >编辑</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <EditFacilitator ref="EditFacilitator" @refresh="getList" />
  </div>
</template>
<script>
import { listCompany } from '@/api/company/company'
import EditFacilitator from './editFacilitator'

export default {
  name: "Facilitator",
  dicts: [
    "apstatus",
  ],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        searchValue: "",
        companyType: 1
      },
      // 总条数
      total: 0,
      dataList: [],
    };
  },
  components: {
    EditFacilitator
  },
  created() {
    this.getList();
  },
  activated() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      listCompany(this.queryParams)
        .then((response) => {
          this.dataList = response.rows;
          this.total = response.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      Object.assign(this.$data.queryParams, this.$options.data().queryParams);
      this.getList();
    },
    handleOpen(id) {
      this.$refs.EditFacilitator.openModal(id)
    },
  }
};
</script>
<style lang="scss" scoped></style>
